package org.example.system.component;

import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.example.system.service.ISysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;
import java.util.Map;

/**
 * @version 1.0.0
 * @className: ResourceRoleRulesHolder
 * @description: 资源与角色访问对应关系操作组件
 * @author: LiJunYi
 * @create: 2023/4/10 14:56
 */
@Component
@Slf4j
public class ResourceRoleRulesHolder {

    @Autowired
    ISysRoleService sysRoleService;

    /**
     * 启动时加载资源角色关系
     */
    @PostConstruct
    public void initResourceRolesMap(){
        Map<String, List<String>> map = sysRoleService.initResourceRolesMap();
        log.info("角色资源关系MAP：{}", JSONUtil.toJsonStr(map));
    }
}
